import request from './axios'
import {DEFAULT_PAGENUM, DEFAULT_PAGESIZE} from "@/constent";

/**
 * 发布pk
 * @param data
 * @returns {Promise<AxiosResponse<any>>}
 */
export const pushPk = (data) => {
    return request.post('/pk/push',data);
}

/**
 * 获取pk列表
 * @param data
 * @returns {Promise<AxiosResponse<any>>}
 */
const initData = {
    pageNum: DEFAULT_PAGENUM,
    pageSize: DEFAULT_PAGENUM
}
export const getPkList = (data = initData) => {
    return request.post('/pk/getPkList',data);
}
/**
 * 发表观点
 * @param data
 * @returns {Promise<AxiosResponse<any>>}
 */
export const addPkResult = (data) => {
    return request.post('/pkresult/addPkResult',data);
}

/**
 * 获取我的pk
 * @param pageSize
 * @returns {*}
 */
export const getMyPk = (pageSize = DEFAULT_PAGESIZE, userId) => {
    return request({
        url:'/pk/getMyPk',
        method:'get',
        params:{
            pageSize,
            userId
        }
    })
}

/**
 * 删除我的pk
 * @param id
 * @returns {*}
 */
export const removePk = (id) => {
    return request({
        url:'/pk/removePk',
        method:'get',
        params:{
            id
        }
    })
}

/**
 * 获得pk详情
 * @param id
 * @returns {*}
 */
export const getPkInfo = (id) => {
    return request({
        url:'/pk/getPkInfo',
        method:'get',
        params:{
            id
        }
    })
}

/**
 * 支持与取消支持
 * @param id
 * @returns {*}
 */
export const addResultNiu = (id) => {
    return request({
        url:'/pkresult/addResultNiu',
        method:'get',
        params:{
            id
        }
    })
}

/**
 * 支持与取消支持
 * @param id
 * @returns {*}
 */
export const removeIdea = (id) => {
    return request({
        url:'/pkresult/removeIdea',
        method:'get',
        params:{
            id
        }
    })
}
